package service

import (
	"dao"
	"pojo/form"
	"pojo/model"
)

// 订单服务层
type OrderService struct {
	dao *dao.OrderDao
}

// 构造订单服务层
func NewOrderService(dao *dao.OrderDao) *OrderService {
	return &OrderService{
		dao: dao,
	}
}

// 保存订单信息
func (this *OrderService) InsertOrder(orderForm *form.OrderForm) error {

	order := &model.Order{
		UserId:    orderForm.UserId,
		UserName:  orderForm.UserName,
		UserPhone: orderForm.UserPhone,
		Price:     orderForm.Price,
		OrderNo:   orderForm.OrderNo,
	}

	_, err := this.dao.InsertOrder(order)

	return err

}
